/** layuiAdmin.std-v1.1.0 LPPL License By http://www.layui.com/admin/ */
 ;layui.define(["admin","table","util"],function(e){
var t=layui.$,i=(layui.admin,layui.table),
l=(layui.element,{
	all:{text:"全部消息",id:"LAY-app-message-all"},
    notice:{text:"通知",id:"LAY-app-message-notice"}
    }),
    a=function(e){
        return'<a href="detail.html?id='+e.id+'">'+e.title
    };
    
	 i.render({
	 elem:"#LAY-app-message-all",
	 url:'/message/queryAllMessageByMesadmid',
	 page:!0,
	 cols:[
		 [{type:"checkbox",fixed:"left"},
		 {field:"mescontent",title:"标题内容",minWidth:300},
		 {field:"mesdate",title:"时间",width:170,}]
		 ],
		 skin:"line",
		 done: function (res, page, count) {
	            var that = this.elem.next();
	           /* console.log(res);*/
	            res.data.forEach(function (item, index) {
	            	/*console.log(item);
	            	console.log(index);*/
	                if (item.messtatus=="0") {
	                    var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("color", "#FF0000");
	                }
	            });
	        }
	 }),
	 i.render({
	 	elem:"#LAY-app-message-notice",
	 	url:'/message/queryAllMessageByStatus',
	 	page:!0,
	 	cols:[
			 [{type:"checkbox",fixed:"left"},
			 {field:"mescontent",title:"标题内容",minWidth:300},
			 {field:"mesdate",title:"时间",width:170,}]
			 ],
			 skin:"line",
			 done: function (res, page, count) {
		            var that = this.elem.next();
		          /* console.log(res);*/
		            res.data.forEach(function (item, index) {
		            	/*console.log(item);*/
		            	/*console.log(item);*/
		                if (item.messtatus=="0") {
		                    var tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css("color", "#FF0000");
		                }
		            });
		        }
		 });
	        var d={
	        	
	           ready:function(e,t){
	           	    var a=l[t],
	           	    d=i.checkStatus(a.id),
	           	    s=d.data;
	           	    return 0===s.length?layer.msg("未选中行"):(layer.msg("标记已读成功",{icon:1}),void i.reload(a.id))},
	           	    
	           readyAll:function(e,t){
	           	    var i=l[t];
	           	    layer.msg(i.text+"：全部已读",{icon:1})
	           	  }
	        };
         	t(".LAY-app-message-btns .layui-btn").on("click",function(){
       		  var e=t(this),
       		  i=e.data("events"),
       		  l=e.data("type");d[i]&&d[i].call(this,e,l)}),e("message",{})
	});